<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout">
<head th:replace="dashboard/header :: header"></head>
<body>
	<div layout:fragment="content">
		
		<div class="container-div">
			<div class="row">
				<div class="col-sm-12 search-collapse">
					<form id="menu-form">
						<!-- 
						<input type="hidden" th:value="${param.applicationId}" id="applicationId" name="condition[applicationId|like]" />	
						 -->
						<div class="select-list">
							<ul>
								<li>
									菜单名称：<input type="text" name="condition[resourceName|like]" />
								</li>
								<li>
									菜单状态：<select name="condition[visible]">
										<option value="">所有</option>
										<option value="0">显示</option>
										<option value="1">隐藏</option>
									</select>
								</li>
								<li>
									<a class="btn btn-primary btn-rounded btn-sm" onclick="$.treeTable.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
									<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
								</li>
							</ul>
						</div>
					</form>
				</div>
					
				<div class="btn-group-sm" id="toolbar" role="group">
				
					<a class="btn btn-success" onclick="$.operate.add(0)">
						<i class="fa fa-plus"></i> 新增
					</a>
					<a class="btn btn-primary" onclick="$.operate.edit()">
						<i class="fa fa-edit"></i> 修改
					</a>
					 
					<a class="btn btn-info" id="expandAllBtn">
						<i class="fa fa-exchange"></i> 展开/折叠
					</a>
				</div>
					<div class="col-sm-12 select-table table-striped">
					<table id="bootstrap-tree-table"></table>
				</div>
			</div>
		</div>	

	</div>

	<input type="hidden" th:value="${param.applicationId}" id="applicationId" name="applicationId" />	

	<footer th:replace="dashboard/footer :: footer"></footer>
	<script type="text/javascript" th:src="@{/resources/js/project.js}"></script>

	<script>
		var prefix = ctx + "boot/platform/menus/" ;
		var applicationId = $("input[name=applicationId]").val() ; 
		$(function() {
		    var options = {
		        code: "id",
		        parentCode: "resourceParent" ,
		        uniqueId:"id" ,
		        rootIdValue: "0" ,
		        refresh: true ,
		        expandAll: false,
		        expandFirst: true ,
		        url: ctx + "boot/platform/menus/menusDatabase?applicationId="+applicationId ,
		        createUrl: ctx + 'boot/platform/menus/add?resourceParent={id}&applicationId='+applicationId ,
		        updateUrl: ctx+"boot/platform/menus/modify?id={id}&applicationId="+applicationId ,
		        statusUrl: ctx+"boot/platform/menus/changeStatus?id={id}" , 
		        cleanUrl: ctx+"boot/platform/menus/cleanAll",
		        detailUrl: ctx+"boot/platform/menus/detail?id={id}",
		        removeUrl: ctx+"boot/platform/menus/delete?ids={id}" ,
		        exportUrl: ctx+"boot/platform/menus/exportExcel",
		        modalName: "菜单",
		        rememberSelected: true,
		        ajaxType: "post" , 
		        columns: [{
                    field: 'selectItem', 
                    radio: true
                 },
                 {
		            title: '菜单名称',
		            field: 'resourceName',
		            width: '20%',
		            formatter: function(value, row, index) {
		                if ($.common.isEmpty(row.resourceIcon)) {
		                    return value ; 
		                } else {
		                    return '<i class="' + row.resourceIcon + '"></i> <span class="nav-label">' + value + '</span>';
		                }
		            }
		        },
		        {
		            field: 'resourceOrder',
		            title: '排序',
		            width: '5%',
		            align: "left"
		        },
		        {
		            field: 'resourceLink',
		            title: '请求地址',
		            width: '25%',
		            align: "left"
		        },
		        {
		            title: '类型',
		            field: 'menuType',
		            width: '10%',
		            align: "left",
		            formatter: function(value, item, index) {
		                if (value == '9') {
		                	return  "<span class='btn btn-primary btn-xs'>中台</span>";  
		                } else if (value == '1') {
		                	return  "<span class='btn btn-primary btn-xs'>目录</span>";  
		                } else if (value == '0') {
		                	return  "<span class='btn btn-danger btn-xs'>功能</span>";  
		                } else if (value == '8') {
		                	return  "<span class='btn btn-success btn-xs'>按钮</span>";  
		                }
		            }
		        },
		        {
		            field: 'visible',
		            title: '可见',
		            width: '7%',
		            align: "left",
		            formatter: function(value, row, index) {
		            	if (row.menuType == '0') {
		                    return '-';
		                }
		            	return value=="1"?"可见":"隐藏" ; 
		            	// return $.table.selectDictLabel(datas, row.visible);
		            }
		        },
		        {
		            field: 'permission',
		            title: '权限标识',
		            width: '15%',
		            align: "left",
		        },
		        {
		            title: '操作',
		            width: '15%',
		            align: "left",
		            formatter: function(value, row, index) {
		                var actions = [];
		                actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id+ '\')"><i class="fa fa-edit"></i>编辑</a> ');
		                actions.push('<a class="btn btn-info btn-xs" href="javascript:void(0)" onclick="$.operate.add(\'' + row.id+ '\')"><i class="fa fa-plus"></i>新增</a> ');
		                actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id+ '\')"><i class="fa fa-trash"></i>删除</a>');
		                return actions.join('');
		            }
		        }]
		    };
		    $.treeTable.init(options);
		});
	</script>

</body>
</html>
